class Driver(object):
    def __init__(self):
        super(Driver, self).__init__()
        self.__signal = {}
        
    def receive(self, kind):
        if self.__signal.has_key(kind): return self.__signal[kind]
        else: return []
    
    def send(self, sig):
        if not self.__signal.has_key(sig.KIND):
            self.__signal[sig.KIND] = []
        self.__signal[sig.KIND].append(sig)
        
    def clear(self):
        self.__signal = {}
      
################################################
# signal classes
################################################
class Signal(object):
    def __init__(self, kind):
        super(Signal, self).__init__()
        self.kind = kind
        
class KeySignal(Signal):
    KIND = 'key'
    def __init__(self, keyname):
        super(KeySignal, self).__init__(KeySignal.KIND)
        self.key = keyname # from pygame.locals
         
class GotoSignal(Signal):
    KIND = 'goto'
    UP = 0
    DOWN = 1
    LEFT = 2
    RIGHT = 3
    def __init__(self, direct):
        super(GotoSignal, self).__init__(GotoSignal.KIND)
        self.direct = direct
        self.distance = 16 # one step one grid 

class CollisionSignal(Signal):
    KIND = 'collision'
    def __init__(self, spr):
        super(CollisionSignal, self).__init__(CollisionSignal.KIND)
        self.spr = spr # map node (x, y)











